package com.yihaodian.cluster;

import com.yihaodian.server.LifeCycleService;

public interface ClusterService extends LifeCycleService {

	/**
	 * Get local node
	 * 
	 * @return
	 */
	public Node getLocalNode();

	/**
	 * current cluster state.
	 * 
	 * @return
	 */
	public ClusterState state();

	/**
	 * a ClusterStateUpdate would become a ClusterChangedEvent,
	 * 
	 * if current node is master node, then publish/broadcast event to other
	 * node.
	 * 
	 */
	public void updateClusterState(ClusterStateUpdate update);

	/**
	 * listening for ClusterState change.
	 */
	public void addClusterStateListener(ClusterStateListener listener);

}
